package com.technique.api.recommend.controller;

import java.security.Principal;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.technique.api.model.User;
import com.technique.api.user.FeifanUserService;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

@Controller
@RequestMapping("/api/recommend")
public class RecommandController {

	@Autowired
	private FeifanUserService feifanUserService;
	
	/**
	 * 商家信息接口
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/timeline")
	public String getTimeline(String placeId){
		JSONObject json = new JSONObject();
		JSONArray array = new JSONArray();
		
		array.add(this.getPlanFake());
		array.add(this.getPlanFake());
		array.add(this.getPlanFake());
		array.add(this.getPlanFake());
		array.add(this.getFakeShop());
		array.add(this.getFakeShop());
		array.add(this.getPlanFake());
		array.add(this.getPlanFake());
		array.add(this.getPlanFake());
		array.add(this.getPlanFake());
		
		json.put("activities", array);
		return json.toString();
	}
	
	
	public JSONObject getPlanFake() {
		
		JSONObject json  =new JSONObject();
		json.put("id", 1001);
		json.put("type", "plan");
		json.put("title", "瑞士超级酷炫10日游");
		JSONObject picJson = new JSONObject();
		picJson.put("small", "http://img2.3lian.com/2014/f2/132/d/1.jpg");
		picJson.put("middle", "http://img2.3lian.com/2014/f2/132/d/1.jpg" );
		json.put("pic", picJson);
		
		json.put("is_favorited", "false");
		json.put("favorite_count", "8.8万人收藏");
		json.put("price", "¥36000/人");
		return json;
	}
	
	public JSONObject getFakeShop(){
		JSONObject json  =new JSONObject();
		json.put("id", 1002);
		json.put("type", "shop");
		json.put("name", "摄影师");
		JSONObject picJson = new JSONObject();
		picJson.put("small", "http://ww2.sinaimg.cn/mw690/6ca46107jw1f7hba38fn9j203k03kt8m.jpg");
		picJson.put("middle", "http://ww2.sinaimg.cn/mw690/6ca46107jw1f7hba38fn9j203k03kt8m.jpg" );
		picJson.put("large", "http://ww2.sinaimg.cn/mw690/6ca46107jw1f7hba38fn9j203k03kt8m.jpg" );

		json.put("pic", picJson);
		json.put("is_followed", "false");
		return json;
	}

	
	@ResponseBody
	@RequestMapping("/plan")
	public String getRecommendPlan(){
		JSONObject json = new JSONObject();
		
		json.put("id", 10001);
		json.put("title", "法国小镇五日游");
		json.put("price", "¥39000/人");
		json.put("services", "[\"服装四套\",\"拍摄景点五个\",\"原片数量300-400张\",\"拍摄微电影\"]");
		
		JSONArray trips = new JSONArray();
		trips.add(this.getFakeTrip("第一天"));
		trips.add(this.getFakeTrip("第二天"));
		trips.add(this.getFakeTrip("第三天"));
		trips.add(this.getFakeTrip("第四天"));



		json.put("trips", trips);
		
		return json.toString();
		
		
	}
	
	
	private JSONObject getFakeTrip(String day){
		JSONObject json = new JSONObject();
		json.put("day", day);
		json.put("place", "阿维尼亚 古城——断桥" );
		
		json.put("detail", "阿维尼亚小镇保留着法国小镇的古朴、纯净，建筑色彩丰富多样。保留着法国小镇的古朴、纯净。建筑色彩丰富多样。保留着法国小镇的古朴、纯净。建筑色彩丰富多样。保留着法国小镇的古朴、纯净。建筑色彩丰富多样。保留着法国小镇的古朴、纯净。");
		JSONObject picJson = new JSONObject();
		picJson.put("small", "http://ww2.sinaimg.cn/mw690/6ca46107jw1f7hba38fn9j203k03kt8m.jpg");
		picJson.put("middle", "http://ww2.sinaimg.cn/mw690/6ca46107jw1f7hba38fn9j203k03kt8m.jpg" );
		picJson.put("large", "http://ww2.sinaimg.cn/mw690/6ca46107jw1f7hba38fn9j203k03kt8m.jpg" );

		
		json.put("pic", picJson);	
		
		return json;
	}

	/**
	 * 行程修改
	 * @return
	 */
	@RequestMapping("/trip_edit")
	public ModelAndView tripEdit(){
		throw new UnsupportedOperationException();
	}
	
	
}
